package com.weaver.drools.business.execution.controller;

import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.weaver.drools.business.execution.entity.OverviewBean;
import com.weaver.drools.business.execution.service.IEAqPnlOverview146Service;
import com.weaver.drools.common.controller.CommonController;
import com.weaver.drools.common.entity.UUsrUser36;
import com.weaver.drools.common.utils.PageTag;

@Controller
public class OverviewAction extends CommonController{
	
	@Autowired
	private IEAqPnlOverview146Service overview146Service;
	
	
	/**
	 * 登录者自己行政处罚总览记录信息查询分页
	 */
	@RequestMapping(value ="overViewSearch",method = RequestMethod.GET)
    public String overViewSearch(HttpServletRequest request,HttpServletResponse response){
		
		return "execution/overViewSearch";
	}
	/**
	 * 登录者自己行政处罚总览记录信息查询分页
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping(value ="overViewList",method = RequestMethod.GET)
    public String overViewList(){
    	UUsrUser36 sessionBean = this.getSessionUserBean();
		String currpagenum= "1";
		String pagenum = this.getRequest().getParameter("pageNum");
        if(pagenum != null && pagenum.length()!=0){
            currpagenum= pagenum ;
        }
        String porStartDate1=this.getRequest().getParameter("porStartDate1");
        String porStartDate2=this.getRequest().getParameter("porStartDate2");
        String reportStarDate1=this.getRequest().getParameter("reportStarDate1");
        String reportStarDate2=this.getRequest().getParameter("reportStarDate2");
        String porType=this.getRequest().getParameter("porType");
        String insUnit=this.getRequest().getParameter("insUnit");
        String phaseId=this.getRequest().getParameter("phaseId");
        String isArchived=this.getRequest().getParameter("isArchived");
        String isQueryDepartmentOtherReportUserRecord=this.getRequest().getParameter("isQueryDepartmentOtherReportUserRecord");
		List<OverviewBean> overViewList=new ArrayList<OverviewBean>();
		int overViewCount=0;
		Long operateType=1L;
		try {
			if(insUnit!=null && !insUnit.equals("")){
				insUnit=URLDecoder.decode(insUnit,"utf-8");
			}
			Long isQueryDepartmentOtherReportUserRecord2=null;
			if(isQueryDepartmentOtherReportUserRecord!=null && !isQueryDepartmentOtherReportUserRecord.equals("")){
				if(isQueryDepartmentOtherReportUserRecord.equals("2")){
					operateType=2L;
					isQueryDepartmentOtherReportUserRecord2=0L;
				}else{
					isQueryDepartmentOtherReportUserRecord2=Long.valueOf(isQueryDepartmentOtherReportUserRecord);
				}
			}
			List list=overview146Service.findList(operateType,porType,currpagenum,"10",insUnit,porStartDate1,porStartDate2,reportStarDate1,reportStarDate2,phaseId,null,isArchived,null,null,isQueryDepartmentOtherReportUserRecord2,sessionBean.getDepartmentid(),sessionBean.getUserid());
			if(list.size()>0){
				overViewCount=Integer.valueOf(list.get(0).toString());
				overViewList=(List<OverviewBean>)list.get(1);
			}
			PageTag<OverviewBean> page = new PageTag<OverviewBean>();
			page.setPageNo(Integer.valueOf(currpagenum));
			page.setPageSize(10);
			page.setResult(overViewList);
			page.setTotalCount(overViewCount);
			this.getRequest().setAttribute("operateType",operateType);
			this.getRequest().setAttribute("currpagenum",currpagenum);
			this.getRequest().setAttribute("isQueryDepartmentOtherReportUserRecord",isQueryDepartmentOtherReportUserRecord);
			this.getRequest().setAttribute("overviewList", overViewList);
			this.getRequest().setAttribute("pageTag", page);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "execution/overViewList";
	}
	
}
